#include "PreCompile.hpp"
#include "GCCOutputParserTests.hpp"
#include "../GCC/GCCOutputParser.hpp"

namespace BuildNG
{
  void GCCOutputParserTests::test_full_error_line()
  {
    GccOutputLine output_line;
    GccOutputLine::parse_gcc_output_line("main.cpp:2:20: error: glibmm.h: No such file or directory",output_line);
    
    assert(output_line.line_type == GccOutputLine::Error);
    assert(output_line.msg == "glibmm.h: No such file or directory"); 
    assert(output_line.error_location.file_name == "main.cpp");
    assert(output_line.error_location.line_number == 2);
    assert(output_line.error_location.column_number == 20);
  }
  
  void GCCOutputParserTests::test_full_warning_line()
  {
    GccOutputLine output_line;
    GccOutputLine::parse_gcc_output_line("main.cpp:2:20: warning: glibmm.h: No such file or directory",output_line);

    assert(output_line.line_type == GccOutputLine::Warning);
    assert(output_line.msg == "glibmm.h: No such file or directory"); 
    assert(output_line.error_location.file_name == "main.cpp");
    assert(output_line.error_location.line_number == 2);
    assert(output_line.error_location.column_number == 20);
  }

  void GCCOutputParserTests::test_empty_line()
  {
    GccOutputLine output_line;
    GccOutputLine::parse_gcc_output_line("",output_line);
    
    assert(output_line.line_type == GccOutputLine::Noise);
  }
  
  void GCCOutputParserTests::test_non_error_line1()
  {
    GccOutputLine output_line;
    GccOutputLine::parse_gcc_output_line("gatomic.c: At top level:",output_line);
    
    assert(output_line.line_type == GccOutputLine::Noise);
  }
  
  void GCCOutputParserTests::test_non_error_line2()
  {
    GccOutputLine output_line;
    GccOutputLine::parse_gcc_output_line("gatomic.c: In function ‘_g_atomic_thread_init’:",output_line);
    
    assert(output_line.line_type == GccOutputLine::Noise);
  }
  
  void GCCOutputParserTests::test_no_column_specified()
  {
    GccOutputLine output_line;
    GccOutputLine::parse_gcc_output_line("main.cpp:2: error: glibmm.h: No such file or directory",output_line);
    
    assert(output_line.line_type == GccOutputLine::Error);
    assert(output_line.msg == "glibmm.h: No such file or directory"); 
    assert(output_line.error_location.file_name == "main.cpp");
    assert(output_line.error_location.line_number == 2);
    assert(output_line.error_location.column_number == -1);
  }
}
